import Vue from "vue";
import {request} from "../../../util/request.js";
import "../../../style/basic.less";
import dialog from "../../../util/dialog.js";
new Vue({
    el:"#louie",
    data:{
        message_media_check:"",
        message_media_pass:"",
    },
    computed:{
        data:function(){
            return {
                message_media_check:this.message_media_check,
                message_media_pass:this.message_media_pass
            }
        }
    },
    created:function(){
        this.get();
    },
    methods:{
        /**
         * 获取参数
         */
        get(){
            request("setting/easyFind",{
                return:["message_media_check","message_media_pass"]
            })
                .then((res)=>{
                    if(res.data.status === "success"){
                        let data = res.data.data;
                        this.message_media_check = data.message_media_check;
                        this.message_media_pass = data.message_media_pass;
                    }
                });
        },
        /**
         * 设置参数
         */
        submit(){
            request("setting/set",{
                data:this.data
            })
                .then((res)=>{
                    if(res.data.status === "success"){
                        dialog.alert(this,"设置成功");
                    }else{
                        dialog.alert(this,"设置失败");
                    }
                });
        },
        /**
         * 自动配置模板消息id
         */
        autoSet(){
            dialog.confirm(this,"确定自动配置模板消息吗？",(res)=>{
                if(res){
                    request("setting/autoSetTpl")
                        .then((res)=>{
                            console.log(res);
                            if(res.data.status === "success"){
                                let data = res.data.data;
                                this.message_media_check = data.message_media_check;
                                this.message_media_pass = data.message_media_pass;
                            }else{
                                dialog.alert(this,res.data.err_msg);
                            }
                        });
                }
            });
        }
    }
});